auth = function(){
    $('body').html(fly.template('http://naima.vn/main.html'));
    $('#tp-right-panel').html('<p><a href="#main/index">Trang chủ quản trị</a> | <a target="_blank" href="'+fly.baseUrl+'/">Trang chủ Naima.vn</a>');
    $('#content').html(fly.template('http://naima.vn/signin.html'));
    $('form[name=login_form]').keyup(function(event){
        if(event.keyCode == 13){
            auth.signin();
        }
    });
}

auth.signin = function(){
    fly.ajax({
        service:'/auth/signin', 
        data:$('form[name=login_form]').serialize(), 
        success:function(result){
            if(result.status){
                viewer = result.data;
                document.location = '#main/index';
            }
            else{
                popup.msg(result.message);
            }
        }
    });
}

auth.signout = function(){
    fly.ajax({
        service:'/auth/signout',
        success: function(result){
            viewer = null;
            document.location = '#main';
        }
    });
}